package com.rosh.rpc.client.proxy;

import net.sf.cglib.proxy.Enhancer;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Author: rosh
 * @Date: 2022/6/14 20:14
 */
@Component
public class CglibProxyFactory {


    public <T> T newProxyInstance(Class<T> cls) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(cls);
        enhancer.setCallback(new CglibProxyCallBackHandler());
        return (T) enhancer.create();
    }

}
